package handler

import (
	"github.com/gin-gonic/gin"
	"post-hub/internal/dto"
	"post-hub/internal/model"
	"post-hub/response"
)

func CreateMessage(c *gin.Context) {

	var message model.Message
	err := c.ShouldBind(&message)
	if err != nil {
		response.Error(c, "解析失败")
		return
	}
	message = model.Message{
		UserId:  message.UserId,
		DistId:  message.DistId,
		Status:  message.Status,
		Content: message.Content,
	}
	err = dto.CreateMessage(&message)
	if err != nil {
		response.Error(c, "推送失败")
		return
	}
	response.Success(c, "推送成功", message.Content)
}
